#ifndef __MSG_QUEUE_H__
#define __MSG_QUEUE_H__

#ifdef  __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdio.h>
#include <pthread.h>

#define ALIGN_SIZE 8

struct msg_queue
{
    int head;
    int tail;
    int count;

    pthread_mutex_t mutex;
    pthread_cond_t full;
    pthread_cond_t empty;

    uint32_t msg_size;
    uint32_t msg_count;

    char *data;
};


struct msg_queue *msg_queue_create(uint32_t msg_size, uint32_t msg_count);

int msg_queue_delete(struct msg_queue *queue);

int msg_queue_send(struct msg_queue *queue, uint8_t *msg, uint32_t msg_size);

int msg_queue_recv(struct msg_queue *queue, uint8_t *msg, uint32_t msg_size);

#ifdef  __cplusplus
}
#endif

#endif /* __MSG_QUEUE_H__ */